<template>
  <div class="search-store">
    <div class="mescroll"  ref="mescroll">
      <div class="item">
        <img src="@/assets/jssy05.png" class="head-img" alt="">
        <div class="name-con">
          <p class="name">{{info.nickname}}(总剩{{info.remain}}次）</p>
          <p class="phone">{{info.mobile}} <span class="num">孩子数量：{{info.child}}</span></p>
        </div>
      </div>
      <div class="join-store">
        <p class="title">{{info.txt}}</p>
        <div class="flex">
          <div class="con">
            <p class="num">{{info.remain}}</p>
            <p class="text">剩余次数</p>
          </div>
          <div class="con">
            <p class="num">{{info.signin}}</p>
            <p class="text">打卡记录</p>
          </div>
        </div>
      </div>
      <div class="record-details">
        <p class="title">记录明细</p>
        <div class="nav-btn clear">
          <span :class="(type == '0') ?'active' : ''" @click="onItemClick(0)">全部</span>
          <span :class="(type == '1') ?'active' : ''" @click="onItemClick(1)">办卡记录</span>
          <span :class="(type == '2') ?'active' : ''" @click="onItemClick(2)">打卡记录</span>
        </div>
      </div>
      <div class="list">
        <div v-for="(item,index) in lists" class="list-item" @click="isJump(item.type,item.id)">
          <div class="type">
            <p class="title">「{{item.type_txt}}」{{item.txt}}</p>
            <p class="time">{{item.create_time}}</p>
          </div>
          <div class="num">
            <p class="title">{{item.num}}次</p>
            <p class="time">剩余{{item.after_num}}次</p>          
          </div>
          <div class="is-comment">
            <p  v-show="item.type==2" v-if='item.review==1'>已点评</p>   
            <p  v-show="item.type==2" v-else>待点评</p>   
          </div>
        </div>
      </div>
      <div class="none" v-show="noDate">
        <img src="@/assets/tykt01.png" alt="">
        <p>暂无相关内容</p>
      </div>
    </div>
    <div class="fixed">
      <div class="flex-div" @click="router({path: './childManage',query:{id:id}})">孩子管理</div>
      <div class="flex-div" @click="router({path: './clock',query:{id:id}})">打卡</div>
      <div class="flex-div" @click="router({path: './applyCard',query:{uid:id}})">办卡</div>
    </div>
  </div>
</template>

<script>
  import {persondetails,cardlog} from '@/api/api'
  import MeScroll from 'mescroll.js'
  import 'mescroll.js/mescroll.min.css'
  export default {
    components: {
    },
    data () {
      return {
        info:[],
        lists:[],
        type:0,
        noDate: false,
      }
    },
    created () {
      this.id = this.$route.query.id
      this.person()
    },
    mounted () {
      this.mescroll = new MeScroll(this.$refs.mescroll, { 
        up: {
          callback: this.upCallback
        }
      })
    },
    methods: {
      router (path) {
        this.$router.push(path)
      },
      person(){
        persondetails(this.id).then((res) =>{
          this.info=res.data.info
        }).catch((err) => {
          console.dir(err)
        })
      },
      onItemClick(index){
        this.type=index
        this.mescroll.resetUpScroll()
      },
      isJump(type,id){
        if(type==2){
          this.router({path: './storeComment',query:{id:id}})
        }
      },
      upCallback (page) {      
        cardlog(this.type,this.id,page.num, page.size).then((res) => {
          if(!res.data.info){
            res.data.info=[]
          }
          if (page.num == 1){
            this.lists = []
          }
          if(res.data == null){
            this.mescroll.endErr()
            return
          }
          this.$nextTick(() => {
            this.mescroll.endSuccess(res.data.info.length);
          })
          this.lists = this.lists.concat(res.data.info)
          if(this.lists.length == "0"){
            this.noDate = true
          }
        }).catch((err) => {
          console.dir(err)
          this.mescroll.endErr()
        })
      },
    }
  }
</script>

<style lang="stylus" scoped>
.search-store
  .mescroll
    position fixed
    top 0
    bottom 0
    height auto
    width 100vw
    background-color #fff
    padding-bottom 6rem
    box-sizing border-box
    .top-img
      float left
    .search
      float left
      width 92%
      margin-left 4%
      text-align center
      background-color #fff
      height 4.5rem
      line-height 4.5rem
      margin-top -2.25rem
      margin-bottom 1rem
      img
        display inline-block
        vertical-align middle
        width 1.6rem
      span
        display inline-block
        vertical-align middle
        font-size 1.3rem
        color #172F6D
        margin-left .5rem
  .item
    padding 1.5rem 0
    overflow hidden
    margin-left 1.5rem
    .head-img
      float left
      width 5rem
      margin-right 1.2rem
    .name-con
      .name
        color #333333
        font-size 1.5rem
        font-weight 500
        line-height 1.8rem
        margin-bottom .8rem
        margin-top .3rem
      .phone
        font-size 1.2rem
        line-height 1.8rem
        color #999
        .num
          border-left .1rem solid #999999
          margin-left 1rem
          padding-left 1rem
  .join-store
    margin-top .6rem
    border-bottom 1rem solid #f5f5f5
    background-image url('../../assets/mdyhzil02.png')
    background-size 100%
    background-repeat no-repeat
    background-position-y -8.7rem
    .title
      line-height 3.9rem
      text-align center
      color #495574
      font-size 1.3rem
      font-weight 500
    .flex
      height 6.5rem
      display flex
      text-align center
      padding 0 3.6rem
      .con
        flex 1
        color #f5f5f5
        margin-top .8rem
        .num
          font-weight bold
          font-size 2.1rem
        .text
          font-size 1.2rem
  .record-details
    .title
      line-height 5.6rem
      height 5.6rem
      font-size 1.7rem
      color #333
      font-weight bold
      padding 0 1.5rem
    .nav-btn
      padding 0 1.5rem
      padding-bottom 1.5rem
      border-bottom 1px solid #e6e6e6
      span
        color #999
        font-size 1.5rem
        border 1px solid #ccc
        width 8.1rem
        height 3.1rem
        line-height 3.1rem
        float left
        text-align center
        margin-right 1.5rem
      span.active
        border 1px solid #172F6D
        color #172F6D
  .fixed
    position fixed
    bottom 0
    height 5rem
    line-height 5rem
    font-size 1.5rem
    text-align center
    display flex
    width 100%
    color #fff
    background-color #fff
    .flex-div
      flex 1
      box-sizing border-box
      &:nth-child(1)
        color #172F6D  
        border-top 1px solid #e6e6e6
      &:nth-child(2)
        background-color #A81E27
      &:nth-child(3)
        background-color #172F6D
  .none
    img
      width 7.25rem
      position relative
      left 50%
      margin-left -3.625rem
      top 5rem
    p
      position relative
      top 6.3rem
      text-align center
      color #666
      font-size 1.3rem
  .list
    border-bottom 1rem solid #f5f5f5
    .list-item
      padding 1.5rem
      display flex
      background-color #fff
      border-bottom 1px solid #e6e6e6
      &:last-child
        border none
      .title
        color #333
        font-size 1.5rem
        font-weight bold
        position relative
        left -.8rem
      .time
        color #999
        font-size 1.2rem
      .type
        flex 2
      .num
        flex 1
        text-align right
      .is-comment
        flex 1
        color #172F6D
        font-size 1.3rem
        line-height 4rem
        height 4rem
        text-align right
</style>
